import LevelInitBase from "../LevelCommon/LevelInitBase";
import LevelControl5 from "../LevelControl/LevelControl5";
import RoomControl from "../LevelCommon/RoomControl";
import { utils } from "../../utils/CommonUtil";
import GamePropObj from "../Prefabs/InteractivObj/Common/GamePropObj";
import FocusParentObj from "../Prefabs/InteractivObj/Common/FocusParentObj";
import CallToLevel from "../Prefabs/CallToLevel";
import RotateObj from "../Prefabs/InteractivObj/Common/RotateObj";
import FocusMoreParentObj from "../Prefabs/InteractivObj/Common/FocusMoreParentObj";
import PasswordBox from "../Prefabs/InteractivObj/PasswordBox/PasswordBox";
import PasswordBoxKey from "../Prefabs/InteractivObj/PasswordBox/PasswordBoxKey";
import MoveObj from "../Prefabs/InteractivObj/Common/MoveObj";

export default class LevelInit5 extends LevelInitBase{
    private room1:Laya.Sprite3D;
    private room2:Laya.Sprite3D;

    private container:Laya.Sprite3D;

    public startInitDetail(){
        this.levelRoot.addComponent(LevelControl5);
        this.room1 = this.LevelObjs.getChildByName("room1") as Laya.Sprite3D;
        this.room1.addComponent(RoomControl);
        this.container = this.room1.getChildByName("Container") as Laya.Sprite3D;

        let walls = this.room1.getChildByName("walls") as Laya.Sprite3D;

        let jinianpin =  this.Scene.getChildByName("jinianpin") as Laya.Sprite3D;
        let GamePropObj_jinianpin = utils.CommonUtils.CustomAddComponent(jinianpin,GamePropObj) as GamePropObj;
        GamePropObj_jinianpin.gamePropId = 11;
        
        let jinianpin1 =  this.Scene.getChildByName("jinianpin (1)") as Laya.Sprite3D;
        let GamePropObj_jinianpin1 = utils.CommonUtils.CustomAddComponent(jinianpin1,GamePropObj) as GamePropObj;
        GamePropObj_jinianpin1.gamePropId = 11;

        let jinianpin2 =  this.Scene.getChildByName("jinianpin (2)") as Laya.Sprite3D;
        let GamePropObj_jinianpin2 = utils.CommonUtils.CustomAddComponent(jinianpin2,GamePropObj) as GamePropObj;
        GamePropObj_jinianpin2.gamePropId = 11;

        //#region wall2

        let wall2 = walls.getChildByName("wall2") as Laya.Sprite3D;
        
        let Organ_box = wall2.getChildByName("Organ box") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(Organ_box,FocusParentObj);

        let checkOnDiamond = Organ_box.getChildByName("checkOnDiamond") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(checkOnDiamond,CallToLevel);

        let ladder = wall2.getChildByName("ladder") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(ladder,CallToLevel);

        let ladder_props = ladder.getChildByName("ladder_props") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(ladder_props,CallToLevel);

        let Valve_obj = wall2.getChildByName("Valve_obj") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(Valve_obj,FocusParentObj);

        let takeOnValve = Valve_obj.getChildByName("takeOnValve") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(takeOnValve,CallToLevel);

        let valve_prop_Water = Valve_obj.getChildByName("valve_prop_Water") as Laya.Sprite3D;
        let RotateObj_valve_prop_Water = utils.CommonUtils.CustomAddComponent(valve_prop_Water,RotateObj) as RotateObj;
        RotateObj_valve_prop_Water.rotateTime = 1000;
        RotateObj_valve_prop_Water.IsRotateOnce = true;
        RotateObj_valve_prop_Water.isNeedCallToLevel = true;
        RotateObj_valve_prop_Water.targetRotate = new Laya.Vector3(0,0,90);


        //#endregion

        let wall3 = walls.getChildByName("wall3") as Laya.Sprite3D;
        let GameObject = wall3.getChildByName("GameObject") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(GameObject,FocusParentObj);

        let wall_props = GameObject.getChildByName("wall_props") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(wall_props,CallToLevel);


        //#region wall3

        let BOX = this.container.getChildByName("boxes").getChildByName("BOX") as Laya.Sprite3D;
        let FocusMoreParent_BOX = utils.CommonUtils.CustomAddComponent(BOX,FocusMoreParentObj) as FocusMoreParentObj;
        FocusMoreParent_BOX.cameraMoveTime = 1200;

        let PasswordBox_BOX = utils.CommonUtils.CustomAddComponent(BOX,PasswordBox) as PasswordBox;
        PasswordBox_BOX.correctIndex.push(2);
        PasswordBox_BOX.correctIndex.push(1);
        PasswordBox_BOX.correctIndex.push(1);
        PasswordBox_BOX.correctIndex.push(3);

        PasswordBox_BOX.haveMoreCorrect = false;

        let box_open_props = BOX.getChildByName("box_open_props") as Laya.Sprite3D;
        let RotateObj_box_open_props =  utils.CommonUtils.CustomAddComponent(box_open_props,RotateObj) as RotateObj;

        RotateObj_box_open_props.rotateTime = 500;
        RotateObj_box_open_props.IsRotateOnce = true;
        RotateObj_box_open_props.VoiceName = "openGate";
        RotateObj_box_open_props.targetRotate = new Laya.Vector3(-50,0,0);

        let valve_props = BOX.getChildByName("valve_props") as Laya.Sprite3D;
        let GamePropObj_valve_props = utils.CommonUtils.CustomAddComponent(valve_props,GamePropObj);
        GamePropObj_valve_props.gamePropId = 24;

        let passworKey = BOX.getChildByName("passworKey") as Laya.Sprite3D;

        let organ_A = passworKey.getChildByName("organ_A") as Laya.Sprite3D;
        let PasswordBoxKey_organ_A = utils.CommonUtils.CustomAddComponent(organ_A,PasswordBoxKey) as PasswordBoxKey;
        PasswordBoxKey_organ_A.rotateAngle = -45;

        let organ_b = passworKey.getChildByName("organ_b") as Laya.Sprite3D;
        let PasswordBoxKey_organ_b = utils.CommonUtils.CustomAddComponent(organ_b,PasswordBoxKey) as PasswordBoxKey;
        PasswordBoxKey_organ_b.rotateAngle = -90;
        
        let organ_c = passworKey.getChildByName("organ_c") as Laya.Sprite3D;
        let PasswordBoxKey_organ_c = utils.CommonUtils.CustomAddComponent(organ_c,PasswordBoxKey) as PasswordBoxKey;
        PasswordBoxKey_organ_c.rotateAngle = -45;

        let organ_d = passworKey.getChildByName("organ_d") as Laya.Sprite3D;
        let PasswordBoxKey_organ_d = utils.CommonUtils.CustomAddComponent(organ_d,PasswordBoxKey) as PasswordBoxKey;
        PasswordBoxKey_organ_d.rotateAngle = -90;

        //#endregion

        //#region container
        let BarrelStack =  this.container.getChildByName("BarrelStack") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(BarrelStack,FocusMoreParentObj);
        let Battery_props = BarrelStack.getChildByName("Battery_props") as Laya.Sprite3D;
        let GamePropObj_Battery_props = utils.CommonUtils.CustomAddComponent(Battery_props,GamePropObj);
        GamePropObj_Battery_props.gamePropId = 25;

        let Cabinet = this.container.getChildByName("Cabinet") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(Cabinet,FocusMoreParentObj);

        let Cabinet_GameObject = Cabinet.getChildByName("GameObject") as Laya.Sprite3D;
        let RotateObj_Cabinet_GameObject = utils.CommonUtils.CustomAddComponent(Cabinet_GameObject,RotateObj) as RotateObj;
        RotateObj_Cabinet_GameObject.rotateTime = 500;
        RotateObj_Cabinet_GameObject.VoiceName = "openGate";
        RotateObj_Cabinet_GameObject.IsRotateOnce = true;
        RotateObj_Cabinet_GameObject.targetRotate = new Laya.Vector3(0,90,0);
        RotateObj_Cabinet_GameObject.isConvertUnityRotation = true;
        

        let Cabinet_GameObject1 = Cabinet.getChildByName("GameObject (1)") as Laya.Sprite3D;
        let RotateObj_Cabinet_GameObject1 = utils.CommonUtils.CustomAddComponent(Cabinet_GameObject1,RotateObj) as RotateObj;
        RotateObj_Cabinet_GameObject1.rotateTime = 500;
        RotateObj_Cabinet_GameObject1.VoiceName = "openGate";
        RotateObj_Cabinet_GameObject1.IsRotateOnce = true;
        RotateObj_Cabinet_GameObject1.targetRotate = new Laya.Vector3(0,-90,0);
        RotateObj_Cabinet_GameObject1.isConvertUnityRotation = true;
        

        let Chainsaw = this.container.getChildByName("Chainsaw") as Laya.Sprite3D;
        let GamePropObj_Chainsaw =  utils.CommonUtils.CustomAddComponent(Chainsaw,GamePropObj) as GamePropObj;
        GamePropObj_Chainsaw.gamePropId = 26;

        let model = this.container.getChildByName("model") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(model,FocusMoreParentObj) as GamePropObj;

        let check_take_on_hand = model.getChildByName("check_take_on_hand") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(check_take_on_hand,CallToLevel);

        let modle_finger_props = model.getChildByName("modle_finger_props") as Laya.Sprite3D;
        let RotateObj_modle_finger_props = utils.CommonUtils.CustomAddComponent(modle_finger_props,RotateObj) as RotateObj;
        RotateObj_modle_finger_props.rotateTime = 500;
        RotateObj_modle_finger_props.IsRotateOnce =  true;
        RotateObj_modle_finger_props.targetRotate = new Laya.Vector3(50,80,43);

        let crystal_props = model.getChildByName("crystal_props") as Laya.Sprite3D;
        let GamePropObj_crystal_props = utils.CommonUtils.CustomAddComponent(crystal_props,GamePropObj) as GamePropObj;
        GamePropObj_crystal_props.gamePropId = 29;
        GamePropObj_crystal_props.isNeedCallToLevel = true;

        let Nuke = this.container.getChildByName("Nuke") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(Nuke,FocusMoreParentObj);
        let Fluorescent_agent_props = Nuke.getChildByName("Fluorescent agent_props") as Laya.Sprite3D;
        let GamePropObj_Fluorescent_agent_props = utils.CommonUtils.CustomAddComponent(Fluorescent_agent_props,GamePropObj) as GamePropObj;
        GamePropObj_Fluorescent_agent_props.gamePropId = 23;

        let water = this.container.getChildByName("water") as Laya.Sprite3D;
        let MoveObj_water = utils.CommonUtils.CustomAddComponent(water,MoveObj) as MoveObj;
        MoveObj_water.tweenTime = 2000;
        MoveObj_water.targetPos = new Laya.Vector3(0.8422284,-1.16,2.68109);

        let shiiti_root = this.container.getChildByName("shiiti_root") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(shiiti_root,FocusMoreParentObj);

        let shiti = shiiti_root.getChildByName("shiti") as Laya.Sprite3D;
        utils.CommonUtils.CustomAddComponent(shiti,CallToLevel);

        let modle_hand_r_props = shiti.getChildByName("modle_hand_r_props") as Laya.Sprite3D;
        let GamePropObj_modle_hand_r_props = utils.CommonUtils.CustomAddComponent(modle_hand_r_props,GamePropObj) as GamePropObj;
        GamePropObj_modle_hand_r_props.gamePropId = 28;
        GamePropObj_modle_hand_r_props.isNeedCallToLevel = true;
    }
}